import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Home from "../views/Home.vue";
import Welcome from "../views/Welcome.vue";
import User from "../views/safty/User.vue";

//路由有bug，需要重写push方法
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error);
};

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Login",
    component: Login
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    children:[
      {
        path:'',
        name:'Welcome',
        component:Welcome
      },
      {
        path:'safty/user',
        name:'User',
        component:User
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

export default router;
